<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:composite="http://xmlns.jcp.org/jsf/composite">

    <h:body>
        <composite:interface>
            <composite:attribute name="bean" required="true"/>
        </composite:interface>

        <composite:implementation>
            <h:form id="personalFilterForm">
                <p:dialog onHide="#{cc.attrs.bean.cancelPersonal()}" id="personalFilterDialog" header="#{messages.Personal}" modal="true" position="top" resizable="false" widgetVar="personalFilterDialog">
                    <p:panel id="personalFilterPanel" styleClass="noBorder noPadding noMargin">
                        <p:selectOneMenu converter="#{sexConverter}" id="selectSearchSex" value="#{cc.attrs.bean.sex}" effect="fade" required="false" label="#{messages.Sex}" requiredMessage="#{messages.SexRequired}">  
                            <f:selectItem itemLabel="#{messages.Sex}" itemValue="" />  
                            <f:selectItem itemLabel="#{messages.Indiferent}" itemValue="" /> 
                            <f:selectItems value="#{userResourcesBean.sexs}" var="sex" itemLabel="#{sexBundle[sex.idSex.toString()]}" itemValue="#{sex}"/>  
                        </p:selectOneMenu>

                        <p:inputText id="minimumAge" value="#{cc.attrs.bean.minAge}" required="false" label="#{messages.MinimumAge}">  
                            <f:convertNumber integerOnly="true" maxIntegerDigits="2" minIntegerDigits="2"></f:convertNumber>
                        </p:inputText>
                        <p:watermark for="minimumAge" value="#{messages.MinimumAge}" />

                        <p:inputText id="maximumAge" value="#{cc.attrs.bean.maxAge}" required="false" label="#{messages.MaximumAge}">  
                            <f:convertNumber integerOnly="true" maxIntegerDigits="2" minIntegerDigits="2"></f:convertNumber>
                        </p:inputText>
                        <p:watermark for="maximumAge" value="#{messages.MaximumAge}" />
                        <p:selectOneMenu filter="true" filterMatchMode="contains" converter="#{countryConverter}" id="selectResidenceCountry" value="#{cc.attrs.bean.residenceCountry}" effect="fade" required="false" label="#{messages.Country}" requiredMessage="#{messages.CountryRequired}">  
                            <f:selectItem itemLabel="#{messages.Country}" itemValue="" />  
                            <f:selectItem itemLabel="#{countryBundle[resourcesBean.spain.idCountry.toString()]}" itemValue="#{resourcesBean.spain}" /> 
                            <f:selectItems value="#{userResourcesBean.countries}" var="residenceCountry" itemLabel="#{countryBundle[residenceCountry.idCountry.toString()]}" itemValue="#{residenceCountry}"/>  
                            <p:ajax event="change" update="selectResidenceProvince selectResidenceTown" />
                        </p:selectOneMenu>

                        <p:selectOneMenu filter="true" filterMatchMode="contains" converter="#{provinceConverter}" id="selectResidenceProvince" value="#{cc.attrs.bean.residenceProvince}" effect="fade" required="false" label="#{messages.Province}" requiredMessage="#{messages.ProvinceRequired}">  
                            <f:selectItem itemLabel="#{messages.Province}" itemValue="" />  
                            <f:selectItems value="#{cc.attrs.bean.residenceCountry.provinceList}" var="residenceProvince" itemLabel="#{residenceProvince.description}" itemValue="#{residenceProvince}"/>  
                            <p:ajax event="change" update="selectResidenceTown" />
                        </p:selectOneMenu>

                        <p:selectOneMenu filter="true" filterMatchMode="contains" converter="#{townConverter}" id="selectResidenceTown" value="#{cc.attrs.bean.residenceTown}" effect="fade" required="false" label="#{messages.Town}" requiredMessage="#{messages.TownRequired}">  
                            <f:selectItem itemLabel="#{messages.Town}" itemValue="" />  
                            <f:selectItems value="#{cc.attrs.bean.residenceProvince.townList}" var="residenceTown" itemLabel="#{residenceTown.description}" itemValue="#{residenceTown}"/>  
                        </p:selectOneMenu>

                        <p:selectOneMenu converter="#{timeAvailabilityConverter}" id="selectMinimumTimeAvailability" value="#{cc.attrs.bean.timeAvailability}" effect="fade" required="false" label="#{messages.TimeAvailability}" requiredMessage="#{messages.TimeAvailabilityRequired}">  
                            <f:selectItem itemLabel="#{messages.MinimumTimeAvailability}" itemValue="" />  
                            <f:selectItems value="#{userResourcesBean.timeAvailabilities}" var="minimumTimeAvailability" itemLabel="#{timeAvailabilityBundle[minimumTimeAvailability.idTimeAvailability.toString()]}" itemValue="#{minimumTimeAvailability}"/>  
                        </p:selectOneMenu>

                        <p:selectOneMenu id="selectRequiredVehicle" value="#{cc.attrs.bean.requiredVehicle}" effect="fade" required="false" label="#{messages.OwnVehicle}" requiredMessage="#{messages.OwnVehicleRequired}">  
                            <f:selectItem itemLabel="#{messages.RequiredVehicle}" itemValue="" />
                            <f:selectItem itemLabel="#{messages.Yes}" itemValue="#{true}" />
                            <f:selectItem itemLabel="#{messages.No}" itemValue="#{false}" />
                        </p:selectOneMenu>
                        <p:commandButton value="#{messages.Add}" process="@parent" styleClass="blueBackgroundStrong" actionListener="#{cc.attrs.bean.addPersonalRequeriments()}" oncomplete="if (args &amp;&amp; !args.validationFailed){PF('personalFilterDialog').hide();reinitWaypoint();}" update=":createSearchForm:searchGrowl :createSearchForm:searchPanel :facesPanel :totalFacesForm :createSearchForm:addFilterPanel" />
                        <p:commandButton value="#{messages.Cancel}" process="@this" styleClass="grayBackgroundStrong" style="margin-left: 3%;" actionListener="#{cc.attrs.bean.cancelPersonal()}" oncomplete="PF('personalFilterDialog').hide();"/>
                    </p:panel>
                </p:dialog>
            </h:form>
        </composite:implementation>
    </h:body>
</html>